import java.util.Arrays;
//希尔排序
public class ShellSrot {
    public static void main(String[] args) {
        int[] array = {8, 1, 4, 9, 0, 3, 5, 2, 7, 6};
        System.out.println(Arrays.toString(array));
        System.out.println();

        for (int gap = array.length / 2; gap > 0; gap /= 2) {

            for (int i = 0; i < array.length; i++) {

                for (int j = i - gap; j >= 0; j -= gap) {

                    if (array[j] > array[j + gap]) {
                        int temp = array[j];
                        array[j] = array[j + gap];
                        array[j + gap] = temp;
                        System.out.println(Arrays.toString(array));
                    } else {
                        break;
                    }
                }
            }
            System.out.println();
        }
    }
}
